import request from "@/utils/request";

export function login(username, password) {
  //console.log(username, password)
  return request({
    url: "/user/login",
    method: "post",
    data: {
      username,
      password
    }
  });
}

export function wxlogin(openid, pid) {
  return request({
    url: "/user/wxlogin",
    method: "post",
    data: {
      openid,
      pid
    }
  });
}

export function reg(username, nickname, password, repassword, pid) {
  return request({
    url: "/user/reg",
    method: "post",
    data: {
      username,
      nickname,
      password,
      repassword,
      pid
    }
  });
}

export function pwdchange(oldpw, password, repassword) {
  return request({
    url: "/user/checkpw",
    method: "post",
    data: { oldpw, password, repassword }
  });
}

export function getInfo(token) {
  return request({
    url: "/user/info",
    method: "get",
    params: {
      token
    }
  });
}

export function logout() {
  return request({
    url: "/user/logout",
    method: "post"
  });
}
